<?php

/**
 * Recipient form base class.
 *
 * @method Recipient getObject() Returns the current form's model object
 *
 * @package    25Mails
 * @subpackage form
 * @author     fabio.lorenzini@25solutions.com
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseRecipientForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'recipient_id'      => new sfWidgetFormInputHidden(),
      'username'          => new sfWidgetFormInputText(),
      'email'             => new sfWidgetFormInputText(),
      'private'           => new sfWidgetFormInputCheckbox(),
      'name'              => new sfWidgetFormInputText(),
      'surname'           => new sfWidgetFormInputText(),
      'businessname'      => new sfWidgetFormTextarea(),
      'country'           => new sfWidgetFormInputText(),
      'language'          => new sfWidgetFormInputText(),
      'subscription'      => new sfWidgetFormInputText(),
      'discount_percent'  => new sfWidgetFormInputText(),
      'free_since'        => new sfWidgetFormDateTime(),
      'pro_since'         => new sfWidgetFormDateTime(),
      'pro_end'           => new sfWidgetFormDateTime(),
      'past_subscription' => new sfWidgetFormInputText(),
      'newsletter'        => new sfWidgetFormInputCheckbox(),
      'active'            => new sfWidgetFormInputCheckbox(),
    ));

    $this->setValidators(array(
      'recipient_id'      => new sfValidatorChoice(array('choices' => array($this->getObject()->get('recipient_id')), 'empty_value' => $this->getObject()->get('recipient_id'), 'required' => false)),
      'username'          => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'email'             => new sfValidatorEmail(array('max_length' => 255, 'required' => false)),
      'private'           => new sfValidatorBoolean(array('required' => false)),
      'name'              => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'surname'           => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'businessname'      => new sfValidatorString(array('required' => false)),
      'country'           => new sfValidatorString(array('max_length' => 2, 'min_length' => 2, 'required' => false)),
      'language'          => new sfValidatorString(array('max_length' => 2, 'min_length' => 2, 'required' => false)),
      'subscription'      => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'discount_percent'  => new sfValidatorInteger(array('required' => false)),
      'free_since'        => new sfValidatorDateTime(array('required' => false)),
      'pro_since'         => new sfValidatorDateTime(array('required' => false)),
      'pro_end'           => new sfValidatorDateTime(array('required' => false)),
      'past_subscription' => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'newsletter'        => new sfValidatorBoolean(array('required' => false)),
      'active'            => new sfValidatorBoolean(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('recipient[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Recipient';
  }

}
